'use strict';//开启验证模式

//引入第三方包 -------------------------开始
import Vue from 'vue';

//引入路由对象
import VueRouter from 'vue-router';
//VueRouter:安装插件
Vue.use(VueRouter)

//Mint:引入mint-ui
import Mint from 'mint-ui';
//Mint:引入css
import 'mint-ui/lib/style.css';
//全局样式
import './static/css/global.css'


//Mint:安装插件
Vue.use(Mint)

//MUI:引mui样式
import './static/vendor/mui/dist/css/mui.css'

//Axios:引入axios
import Axios from 'axios';
//Axios:挂载原型
Vue.prototype.$ajax = Axios;
//引入qs
import qs from 'qs';
Vue.prototype.$qs = qs;

//Axios:默认配置
Axios.defaults.baseURL = 'http://localhost:9502/'
//Axios:拦截器操作loadding
Axios.interceptors.request.use(function (config) {
    //显示图标
    Mint.Indicator.open({
        test: '加载中...',
        spinnerType: 'fading-circle',
    });
    return config;
});
Axios.interceptors.response.use(function (config) {
    //隐藏图标
    Mint.Indicator.close();
    //获取到config中的data,进行加工
    return config;
});


//Moment:引入moment 处理时间格式
import Moment from 'moment';

//VuePreview:引入vue-preview
import VuePreview from 'vue-preview'

Vue.use(VuePreview);


//引入第三方包 -------------------------结束

//引入全局组件需要的组件对象 开始
import NavBar from './components/common/navBar.vue';
import Comment from './components/common/comment.vue';
import MySwipe from './components/common/mySwipe.vue';
//引入全局组件需要的组件对象 结束

//定义成全局组件或过滤器，大家都能使用 开始
Vue.filter('convertDate', function (value) {
    return Moment(value).format('YYYY-MM-DD HH:mm:ss');
});
Vue.component('navBar', NavBar); //使用最好以nav-bar
Vue.component('comment', Comment); //使用最好以comment
Vue.component('mySwipe', MySwipe); //使用最好以my_swipe
//定义全局组件或过滤器 结束

//=================================================================
//引入自己的vue文件 ********************开始
import App from './app.vue'
import Home from './components/home/home.vue'
import Member from './components/member/member.vue'
import Search from './components/search/search.vue'
import ShopCart from './components/shopcart/shopCart.vue'
import NewList from './components/news/newsList.vue'
import NewDetail from './components/news/newDetail.vue'
import PhotoShare from './components/photo/photoShare.vue'
import PhotoDetail from './components/photo/photoDetail.vue'
import GoodsShare from './components/goods/goodsShare.vue'
import GoodsDetail from './components/goods/goodsDetail.vue'
import GoodsComment from './components/goods/goodsComment.vue'
import GoodsPictureInfo from './components/goods/goodsPictureInfo.vue'


//引入自己的vue文件 ********************结束


//VueRouter:创建对象并配置路由规则
let router = new VueRouter({
    linkActiveClass: 'mui-active',
    routes: [
        //VueRouter: 配置路由规则
        {
            path: '/',
            redirect: {name: 'home'}
        },
        {
            name: 'home',
            path: '/home',
            component: Home
        },
        {
            name: 'member',
            path: '/member',
            component: Member
        },
        {
            name: 'search',
            path: '/search',
            component: Search
        },
        {
            name: 'shopcart',
            path: '/shopcart',
            component: ShopCart
        },
        {
            name: 'news.list',
            path: '/news/list',
            component: NewList
        },
        //query ?id=xxx
        {
            name: 'news.detail',
            path: '/news/detail',
            component: NewDetail
        },
        {
            name: 'photo.share',
            path: '/photo/share',
            component: PhotoShare
        },
        //params /xx
        {
            name: 'photo.detail',
            path: '/photo/detail/:id',
            component: PhotoDetail
        },
        {
            name: 'goods.list',
            path: '/goods/list',
            component: GoodsShare
        },
        {
            name: 'goods.detail',
            path: '/goods/detail',
            component: GoodsDetail
        },
        {
            name: 'goods.comment',
            path: '/goods/comment',
            component: GoodsComment
        },
        {
            name: 'goods.pictureInfo',
            path: '/goods/pictureInfo',
            component: GoodsPictureInfo
        },

    ]
})


//创建vue实例
new Vue({
    el: '#app',
    router,
    render: c => c(App)
})

